# Last Change: Sun Nov 02 06:00 PM 2008 J
# vim:syntax=python
from os.path import join as pjoin

from numscons import GetNumpyEnvironment, CheckF77Clib

env = GetNumpyEnvironment(ARGUMENTS)

t = env.Tool('f2py')

config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib})
if not config.CheckF77Clib():
    raise RuntimeError("Could not get C/F77 runtime information")
config.CheckF77Mangling()
config.Finish()

# Statlib library
src = [pjoin("statlib", s) for s in [ "ansari.f", "spearman.f", "swilk.f"]]
env.DistutilsStaticExtLibrary('statlibimp', source = src)

env.AppendUnique(LIBPATH = '.')

# Statlib extension
env.NumpyPythonExtension('statlib', source = 'statlib.pyf', 
                         F2PYOPTIONS = ["--no-wrap-functions"],
                         LIBS = 'statlibimp')

# futil extension
futil_src = env.F2py(pjoin('futilmodule.c'), pjoin('futil.f'))
env.NumpyPythonExtension('futil', source = futil_src + ['futil.f'])

# mvn extension
env.NumpyPythonExtension('mvn', source = ['mvn.pyf', 'mvndst.f'])

# vonmisses_cython extension
env.NumpyPythonExtension('vonmises_cython', source = ['vonmises_cython.c'])
